<template>
	<div class="refresh-btn">
    <!--活动未开始 刷新/去详情按钮组-->
    <div class="refresh-btn-wrap">
      <div class="btn-item refresh" @click="refresh">刷新抢宝</div>
      <div class="btn-item buynow" @click="linkTo(detailAll.buy_link)" v-show="detailAll.is_marketing_buy==1">立即购买</div>
    </div>
  </div>
</template>

<script>
import Vue from 'vue'
import { openPage} from '@/utils/utils'
  /**
   * @Author: yqe@360shop.cn
   * @Date: 2019-12-04 19:43:18
   * @Last Modified by: yqe@360shop.cn
   * @Last Modified time: 2019-12-04 19:43:23
   */
  export default Vue.extend({
    name: 'index',
    props: {
      detailAll: {
        type: Object
      }
    },
    methods: {
      // 刷新抢宝
      refresh() {
        // TODO 小程序使用广播
        if (process.env.isMinniprogram) {
          window.$$publish('refreshMiaosha', true)
        } else {
          window.location.reload()
        }
      },
      linkTo(url) {
        if (url) {
          openPage(url)
        }
      }
    }
  })
</script>

<style lang="scss">
  @import 'src/styles/mixin';
  .refresh-btn{
    width: 100%;
    &-wrap{
      display: flex;
      flex-direction: row;
      border-radius: 40px;
      overflow: hidden;
      .btn-item{
        flex: 1;
        line-height: 28px;
        font-size: 28px;
        padding: 24px 0;
        text-align: center;
        color: #fff;
        font-weight: 700;
        &.refresh{
          @include gradient(right,#FFAE00,#FF8A02);
        }
        &.buynow{
          @include gradient(right,#FE1B49,#E90104);
        }
      }
    }
  }
</style>
